<template>
    <div class="hello">
        <x-header >登陆</x-header>
        <div style="position: absolute;width: 100%;">
            <group>
                <x-input v-model="email" title="邮箱" name="email" placeholder="请输入邮箱地址" is-type="email"></x-input>
                <x-input v-model="password" title="密码" name="password" type="password" placeholder="请输入密码"></x-input>
            </group>

            <x-button type="primary" :disabled="disable001" @click.native="processButton001">羽毛球</x-button>
            <x-button type="primary" :disabled="disable001" @click.native="processButton002">导游</x-button>

        </div>
    </div>
</template>

<script>
    import { Group, Cell, Tabbar, TabbarItem, Swiper, SwiperItem } from '_vux@2.9.3@vux'
    import {http} from '@/hos/http'
    import {api, LoginWay} from '@/api'

    export default {
        components: {
            Group,
            Cell,
            Tabbar,
            TabbarItem,
            Swiper,
            SwiperItem
        },
        name: 'EmailLogin',
        data () {
            return {
                email: '3074402028@qq.com',
                password: 'qwertyuiop',
                disable001: false
            }
        },
        methods: {
            processButton001 () {
                this.disable001 = true
                http.post('https://h5.henortek.cn/App/appLogin', {email: this.email, password: this.password}, {}).then((resp) => {
                    this.$store.commit('setShare', {cmd_key: resp.data.cmd_key})
                    api.bindSession3rd('https://h5.henortek.cn', resp.data.cmd_key, LoginWay.EMAIL)
                    // alert(JSON.stringify(resp))
                    // api.post('Badminton/pkNear', {R: 2000000, longitude: 1, latitude: 2, page: 1, page_size: 2}, (data) => { alert(JSON.stringify(data)) }, (error) => { alert(JSON.stringify(error)) })
                    this.$router.replace('/YyqMain')
                }, (error) => {
                    alert(JSON.stringify(error))
                })
                this.disable001 = false
            },
            processButton002 () {
                this.disable001 = true
                http.post('https://h5.henortek.cn/App/appLogin', {email: this.email, password: this.password}, {}).then((resp) => {
                    this.$store.commit('setShare', {cmd_key: resp.data.cmd_key})
                    api.bindSession3rd('https://h5.henortek.cn', resp.data.cmd_key, LoginWay.EMAIL)
                    // alert(JSON.stringify(resp))
                    // api.post('Badminton/pkNear', {R: 2000000, longitude: 1, latitude: 2, page: 1, page_size: 2}, (data) => { alert(JSON.stringify(data)) }, (error) => { alert(JSON.stringify(error)) })
                    this.$router.replace('/Tourguide')
                }, (error) => {
                    alert(JSON.stringify(error))
                })
                this.disable001 = false
            }
        },
        beforeDestroy () {
            // TODO 关闭ajax
            alert('被销毁了')
        }
    }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
    h1, h2 {
        font-weight: normal;
    }
    ul {
        list-style-type: none;
        padding: 0;
    }
    li {
        display: inline-block;
        margin: 0 10px;
    }
    a {
        color: #42b983;
    }
</style>
